package com.hq.service;

import com.hq.bean.Users;
import com.hq.dao.CompanyDAO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Resource
    private CompanyDAO companyDAO;

    @Override
    public Map login(Users users) {
        return companyDAO.login(users);
    }

    @Override
    public List list() {
        List<Map> list = companyDAO.list();
        double fallmoney=0;
        double yallmoney=0;
        for (Map map : list) {
            fallmoney+=(Double)map.get("fmoney");
            yallmoney+=(Double)map.get("ymoney");

        }
        //
        list.get(0).put("fallmoney",fallmoney/list.size());
        list.get(0).put("yallmoney",yallmoney/list.size());
        return list;
    }

    @Override
    public List manageList(String stime, Integer cid) {
        return companyDAO.manageList(stime,cid);
    }
}
